package sample.shared;

import java.util.HashMap;

public class FileExtensions
{
  public static final String EMAIL = "Emails";

  public static final String EXCEL = "Excel";

  public static final String WORD = "Word";
  
  public static final String PDF = "PDF";
  
  public static final String OTHER = "Other";
  
  private static String[] wordExtensions = { "doc", "docx" };

  private static String[] excelExtensions = { "xls", "xlsx", "csv" };
  
  private static String[] pdfExtensions = { "pdf" };

  private static String[] emailExtensions = { "msg" };


  private static HashMap<String, String> file2typeMap = null;

  static {
    file2typeMap = new HashMap<String, String>();
    for (String doc : wordExtensions) {
      file2typeMap.put(doc, WORD);
    }
    for (String xl : excelExtensions) {
      file2typeMap.put(xl, EXCEL);
    }
    for (String pdf : pdfExtensions) {
      file2typeMap.put(pdf, PDF);
    }
    for (String email : emailExtensions) {
      file2typeMap.put(email, EMAIL);
    }
  }

  public static String getType(String ext) {
    if (file2typeMap.containsKey(ext)) {
      return file2typeMap.get(ext);
    }
    else {
      return OTHER;
    }
  }
}
